{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>﻿id</th>\n",
       "      <th>dur</th>\n",
       "      <th>proto</th>\n",
       "      <th>service</th>\n",
       "      <th>state</th>\n",
       "      <th>spkts</th>\n",
       "      <th>dpkts</th>\n",
       "      <th>sbytes</th>\n",
       "      <th>dbytes</th>\n",
       "      <th>rate</th>\n",
       "      <th>...</th>\n",
       "      <th>ct_dst_sport_ltm</th>\n",
       "      <th>ct_dst_src_ltm</th>\n",
       "      <th>is_ftp_login</th>\n",
       "      <th>ct_ftp_cmd</th>\n",
       "      <th>ct_flw_http_mthd</th>\n",
       "      <th>ct_src_ltm</th>\n",
       "      <th>ct_srv_dst</th>\n",
       "      <th>is_sm_ips_ports</th>\n",
       "      <th>attack_cat</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>0.000011</td>\n",
       "      <td>udp</td>\n",
       "      <td>-</td>\n",
       "      <td>INT</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>496</td>\n",
       "      <td>0</td>\n",
       "      <td>90909.0902</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>0.000008</td>\n",
       "      <td>udp</td>\n",
       "      <td>-</td>\n",
       "      <td>INT</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1762</td>\n",
       "      <td>0</td>\n",
       "      <td>125000.0003</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>0.000005</td>\n",
       "      <td>udp</td>\n",
       "      <td>-</td>\n",
       "      <td>INT</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>1068</td>\n",
       "      <td>0</td>\n",
       "      <td>200000.0051</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>0.000006</td>\n",
       "      <td>udp</td>\n",
       "      <td>-</td>\n",
       "      <td>INT</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>900</td>\n",
       "      <td>0</td>\n",
       "      <td>166666.6608</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0.000010</td>\n",
       "      <td>udp</td>\n",
       "      <td>-</td>\n",
       "      <td>INT</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>2126</td>\n",
       "      <td>0</td>\n",
       "      <td>100000.0025</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>Normal</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 45 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   ﻿id       dur proto service state  spkts  dpkts  sbytes  dbytes  \\\n",
       "0    1  0.000011   udp       -   INT      2      0     496       0   \n",
       "1    2  0.000008   udp       -   INT      2      0    1762       0   \n",
       "2    3  0.000005   udp       -   INT      2      0    1068       0   \n",
       "3    4  0.000006   udp       -   INT      2      0     900       0   \n",
       "4    5  0.000010   udp       -   INT      2      0    2126       0   \n",
       "\n",
       "          rate  ...    ct_dst_sport_ltm  ct_dst_src_ltm  is_ftp_login  \\\n",
       "0   90909.0902  ...                   1               2             0   \n",
       "1  125000.0003  ...                   1               2             0   \n",
       "2  200000.0051  ...                   1               3             0   \n",
       "3  166666.6608  ...                   1               3             0   \n",
       "4  100000.0025  ...                   1               3             0   \n",
       "\n",
       "   ct_ftp_cmd  ct_flw_http_mthd  ct_src_ltm  ct_srv_dst  is_sm_ips_ports  \\\n",
       "0           0                 0           1           2                0   \n",
       "1           0                 0           1           2                0   \n",
       "2           0                 0           1           3                0   \n",
       "3           0                 0           2           3                0   \n",
       "4           0                 0           2           3                0   \n",
       "\n",
       "   attack_cat  label  \n",
       "0      Normal      0  \n",
       "1      Normal      0  \n",
       "2      Normal      0  \n",
       "3      Normal      0  \n",
       "4      Normal      0  \n",
       "\n",
       "[5 rows x 45 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# load the UNSW_NB15 training dataset\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "#df = pd.read_csv('https://www.unsw.adfa.edu.au/australian-centre-for-cyber-security/cybersecurity/ADFA-NB15-Datasets/a%20part%20of%20training%20and%20testing%20set/UNSW_NB15_training-set.csv') # read in the csv file\n",
    "df = pd.read_csv('C:/Users/sg0207348/Documents/smu/UNSW_NB15_training_set.csv') # read in the csv file\n",
    "\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>﻿id</th>\n",
       "      <th>dur</th>\n",
       "      <th>spkts</th>\n",
       "      <th>dpkts</th>\n",
       "      <th>sbytes</th>\n",
       "      <th>dbytes</th>\n",
       "      <th>rate</th>\n",
       "      <th>sttl</th>\n",
       "      <th>dttl</th>\n",
       "      <th>sload</th>\n",
       "      <th>...</th>\n",
       "      <th>ct_src_dport_ltm</th>\n",
       "      <th>ct_dst_sport_ltm</th>\n",
       "      <th>ct_dst_src_ltm</th>\n",
       "      <th>is_ftp_login</th>\n",
       "      <th>ct_ftp_cmd</th>\n",
       "      <th>ct_flw_http_mthd</th>\n",
       "      <th>ct_src_ltm</th>\n",
       "      <th>ct_srv_dst</th>\n",
       "      <th>is_sm_ips_ports</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>8.233200e+04</td>\n",
       "      <td>8.233200e+04</td>\n",
       "      <td>8.233200e+04</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>8.233200e+04</td>\n",
       "      <td>...</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "      <td>82332.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>41166.500000</td>\n",
       "      <td>1.006756</td>\n",
       "      <td>18.666472</td>\n",
       "      <td>17.545936</td>\n",
       "      <td>7.993908e+03</td>\n",
       "      <td>1.323379e+04</td>\n",
       "      <td>8.241089e+04</td>\n",
       "      <td>180.967667</td>\n",
       "      <td>95.713003</td>\n",
       "      <td>6.454902e+07</td>\n",
       "      <td>...</td>\n",
       "      <td>4.928898</td>\n",
       "      <td>3.663011</td>\n",
       "      <td>7.456360</td>\n",
       "      <td>0.008284</td>\n",
       "      <td>0.008381</td>\n",
       "      <td>0.129743</td>\n",
       "      <td>6.468360</td>\n",
       "      <td>9.164262</td>\n",
       "      <td>0.011126</td>\n",
       "      <td>0.550600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>23767.345519</td>\n",
       "      <td>4.710444</td>\n",
       "      <td>133.916353</td>\n",
       "      <td>115.574086</td>\n",
       "      <td>1.716423e+05</td>\n",
       "      <td>1.514715e+05</td>\n",
       "      <td>1.486204e+05</td>\n",
       "      <td>101.513358</td>\n",
       "      <td>116.667722</td>\n",
       "      <td>1.798618e+08</td>\n",
       "      <td>...</td>\n",
       "      <td>8.389545</td>\n",
       "      <td>5.915386</td>\n",
       "      <td>11.415191</td>\n",
       "      <td>0.091171</td>\n",
       "      <td>0.092485</td>\n",
       "      <td>0.638683</td>\n",
       "      <td>8.543927</td>\n",
       "      <td>11.121413</td>\n",
       "      <td>0.104891</td>\n",
       "      <td>0.497436</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.400000e+01</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>20583.750000</td>\n",
       "      <td>0.000008</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.140000e+02</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>2.860611e+01</td>\n",
       "      <td>62.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.120247e+04</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>41166.500000</td>\n",
       "      <td>0.014138</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>5.340000e+02</td>\n",
       "      <td>1.780000e+02</td>\n",
       "      <td>2.650177e+03</td>\n",
       "      <td>254.000000</td>\n",
       "      <td>29.000000</td>\n",
       "      <td>5.770032e+05</td>\n",
       "      <td>...</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>61749.250000</td>\n",
       "      <td>0.719360</td>\n",
       "      <td>12.000000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>1.280000e+03</td>\n",
       "      <td>9.560000e+02</td>\n",
       "      <td>1.111111e+05</td>\n",
       "      <td>254.000000</td>\n",
       "      <td>252.000000</td>\n",
       "      <td>6.514286e+07</td>\n",
       "      <td>...</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>11.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>82332.000000</td>\n",
       "      <td>59.999989</td>\n",
       "      <td>10646.000000</td>\n",
       "      <td>11018.000000</td>\n",
       "      <td>1.435577e+07</td>\n",
       "      <td>1.465753e+07</td>\n",
       "      <td>1.000000e+06</td>\n",
       "      <td>255.000000</td>\n",
       "      <td>253.000000</td>\n",
       "      <td>5.268000e+09</td>\n",
       "      <td>...</td>\n",
       "      <td>59.000000</td>\n",
       "      <td>38.000000</td>\n",
       "      <td>63.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>16.000000</td>\n",
       "      <td>60.000000</td>\n",
       "      <td>62.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8 rows × 41 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                ﻿id           dur         spkts         dpkts        sbytes  \\\n",
       "count  82332.000000  82332.000000  82332.000000  82332.000000  8.233200e+04   \n",
       "mean   41166.500000      1.006756     18.666472     17.545936  7.993908e+03   \n",
       "std    23767.345519      4.710444    133.916353    115.574086  1.716423e+05   \n",
       "min        1.000000      0.000000      1.000000      0.000000  2.400000e+01   \n",
       "25%    20583.750000      0.000008      2.000000      0.000000  1.140000e+02   \n",
       "50%    41166.500000      0.014138      6.000000      2.000000  5.340000e+02   \n",
       "75%    61749.250000      0.719360     12.000000     10.000000  1.280000e+03   \n",
       "max    82332.000000     59.999989  10646.000000  11018.000000  1.435577e+07   \n",
       "\n",
       "             dbytes          rate          sttl          dttl         sload  \\\n",
       "count  8.233200e+04  8.233200e+04  82332.000000  82332.000000  8.233200e+04   \n",
       "mean   1.323379e+04  8.241089e+04    180.967667     95.713003  6.454902e+07   \n",
       "std    1.514715e+05  1.486204e+05    101.513358    116.667722  1.798618e+08   \n",
       "min    0.000000e+00  0.000000e+00      0.000000      0.000000  0.000000e+00   \n",
       "25%    0.000000e+00  2.860611e+01     62.000000      0.000000  1.120247e+04   \n",
       "50%    1.780000e+02  2.650177e+03    254.000000     29.000000  5.770032e+05   \n",
       "75%    9.560000e+02  1.111111e+05    254.000000    252.000000  6.514286e+07   \n",
       "max    1.465753e+07  1.000000e+06    255.000000    253.000000  5.268000e+09   \n",
       "\n",
       "           ...       ct_src_dport_ltm  ct_dst_sport_ltm  ct_dst_src_ltm  \\\n",
       "count      ...           82332.000000      82332.000000    82332.000000   \n",
       "mean       ...               4.928898          3.663011        7.456360   \n",
       "std        ...               8.389545          5.915386       11.415191   \n",
       "min        ...               1.000000          1.000000        1.000000   \n",
       "25%        ...               1.000000          1.000000        1.000000   \n",
       "50%        ...               1.000000          1.000000        3.000000   \n",
       "75%        ...               4.000000          3.000000        6.000000   \n",
       "max        ...              59.000000         38.000000       63.000000   \n",
       "\n",
       "       is_ftp_login    ct_ftp_cmd  ct_flw_http_mthd    ct_src_ltm  \\\n",
       "count  82332.000000  82332.000000      82332.000000  82332.000000   \n",
       "mean       0.008284      0.008381          0.129743      6.468360   \n",
       "std        0.091171      0.092485          0.638683      8.543927   \n",
       "min        0.000000      0.000000          0.000000      1.000000   \n",
       "25%        0.000000      0.000000          0.000000      1.000000   \n",
       "50%        0.000000      0.000000          0.000000      3.000000   \n",
       "75%        0.000000      0.000000          0.000000      7.000000   \n",
       "max        2.000000      2.000000         16.000000     60.000000   \n",
       "\n",
       "         ct_srv_dst  is_sm_ips_ports         label  \n",
       "count  82332.000000     82332.000000  82332.000000  \n",
       "mean       9.164262         0.011126      0.550600  \n",
       "std       11.121413         0.104891      0.497436  \n",
       "min        1.000000         0.000000      0.000000  \n",
       "25%        2.000000         0.000000      0.000000  \n",
       "50%        5.000000         0.000000      1.000000  \n",
       "75%       11.000000         0.000000      1.000000  \n",
       "max       62.000000         1.000000      1.000000  \n",
       "\n",
       "[8 rows x 41 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "﻿id                    int64\n",
      "dur                  float64\n",
      "proto                 object\n",
      "service               object\n",
      "state                 object\n",
      "spkts                  int64\n",
      "dpkts                  int64\n",
      "sbytes                 int64\n",
      "dbytes                 int64\n",
      "rate                 float64\n",
      "sttl                   int64\n",
      "dttl                   int64\n",
      "sload                float64\n",
      "dload                float64\n",
      "sloss                  int64\n",
      "dloss                  int64\n",
      "sinpkt               float64\n",
      "dinpkt               float64\n",
      "sjit                 float64\n",
      "djit                 float64\n",
      "swin                   int64\n",
      "stcpb                  int64\n",
      "dtcpb                  int64\n",
      "dwin                   int64\n",
      "tcprtt               float64\n",
      "synack               float64\n",
      "ackdat               float64\n",
      "smean                  int64\n",
      "dmean                  int64\n",
      "trans_depth            int64\n",
      "response_body_len      int64\n",
      "ct_srv_src             int64\n",
      "ct_state_ttl           int64\n",
      "ct_dst_ltm             int64\n",
      "ct_src_dport_ltm       int64\n",
      "ct_dst_sport_ltm       int64\n",
      "ct_dst_src_ltm         int64\n",
      "is_ftp_login           int64\n",
      "ct_ftp_cmd             int64\n",
      "ct_flw_http_mthd       int64\n",
      "ct_src_ltm             int64\n",
      "ct_srv_dst             int64\n",
      "is_sm_ips_ports        int64\n",
      "attack_cat            object\n",
      "label                  int64\n",
      "dtype: object\n",
      "<bound method DataFrame.info of          ﻿id       dur proto service state  spkts  dpkts  sbytes  dbytes  \\\n",
      "0          1  0.000011   udp       -   INT      2      0     496       0   \n",
      "1          2  0.000008   udp       -   INT      2      0    1762       0   \n",
      "2          3  0.000005   udp       -   INT      2      0    1068       0   \n",
      "3          4  0.000006   udp       -   INT      2      0     900       0   \n",
      "4          5  0.000010   udp       -   INT      2      0    2126       0   \n",
      "5          6  0.000003   udp       -   INT      2      0     784       0   \n",
      "6          7  0.000006   udp       -   INT      2      0    1960       0   \n",
      "7          8  0.000028   udp       -   INT      2      0    1384       0   \n",
      "8          9  0.000000   arp       -   INT      1      0      46       0   \n",
      "9         10  0.000000   arp       -   INT      1      0      46       0   \n",
      "10        11  0.000000   arp       -   INT      1      0      46       0   \n",
      "11        12  0.000000   arp       -   INT      1      0      46       0   \n",
      "12        13  0.000004   udp       -   INT      2      0    1454       0   \n",
      "13        14  0.000007   udp       -   INT      2      0    2062       0   \n",
      "14        15  0.000011   udp       -   INT      2      0    2040       0   \n",
      "15        16  0.000004   udp       -   INT      2      0    1052       0   \n",
      "16        17  0.000003   udp       -   INT      2      0     314       0   \n",
      "17        18  0.000010   udp       -   INT      2      0    1774       0   \n",
      "18        19  0.000002   udp       -   INT      2      0    1568       0   \n",
      "19        20  0.000004   udp       -   INT      2      0    2054       0   \n",
      "20        21  0.000010   udp       -   INT      2      0    2170       0   \n",
      "21        22  0.000009   udp       -   INT      2      0     202       0   \n",
      "22        23  0.000010   udp       -   INT      2      0    1334       0   \n",
      "23        24  0.000005   udp       -   INT      2      0    2058       0   \n",
      "24        25  0.000003   udp       -   INT      2      0     286       0   \n",
      "25        26  0.000007   udp       -   INT      2      0    1500       0   \n",
      "26        27  0.000006   udp       -   INT      2      0     902       0   \n",
      "27        28  0.000002   udp       -   INT      2      0    1626       0   \n",
      "28        29  0.000007   udp       -   INT      2      0     364       0   \n",
      "29        30  1.434166   tcp       -   FIN     10      6     530     268   \n",
      "...      ...       ...   ...     ...   ...    ...    ...     ...     ...   \n",
      "82302  82303  0.449797   tcp       -   FIN     10      6     588     268   \n",
      "82303  82304  0.870010   tcp       -   FIN     10      6     588     268   \n",
      "82304  82305  1.766424   tcp       -   FIN     10      8     588     354   \n",
      "82305  82306  1.025080   tcp       -   FIN     10      6     588     268   \n",
      "82306  82307  0.498365   tcp       -   FIN     10      6     588     268   \n",
      "82307  82308  0.971427   tcp       -   FIN     10      8     588     354   \n",
      "82308  82309  0.467263   tcp       -   FIN     10      6     588     268   \n",
      "82309  82310  1.026355   tcp       -   FIN     10      8     588     354   \n",
      "82310  82311  1.363057   tcp       -   FIN     10      8     588     354   \n",
      "82311  82312  0.888738   tcp       -   FIN     10      6     588     268   \n",
      "82312  82313  1.173606   tcp       -   FIN     10      8     588     354   \n",
      "82313  82314  0.000009   udp       -   INT      2      0     104       0   \n",
      "82314  82315  0.524434   tcp       -   FIN     10      6     588     268   \n",
      "82315  82316  0.000001   udp       -   INT      2      0     104       0   \n",
      "82316  82317  0.000001   udp       -   INT      2      0     104       0   \n",
      "82317  82318  0.947039   tcp       -   FIN     10      6     588     268   \n",
      "82318  82319  0.000009   udp       -   INT      2      0     104       0   \n",
      "82319  82320  0.811914   tcp       -   FIN     10      6     588     268   \n",
      "82320  82321  0.000010   udp       -   INT      2      0     104       0   \n",
      "82321  82322  0.000001   udp       -   INT      2      0     104       0   \n",
      "82322  82323  0.000004   udp       -   INT      2      0     104       0   \n",
      "82323  82324  5.167410   tcp       -   FIN    108     24  138067    1042   \n",
      "82324  82325  0.000006   udp       -   INT      2      0     104       0   \n",
      "82325  82326  0.000010   udp       -   INT      2      0     104       0   \n",
      "82326  82327  0.000009   udp       -   INT      2      0     104       0   \n",
      "82327  82328  0.000005   udp       -   INT      2      0     104       0   \n",
      "82328  82329  1.106101   tcp       -   FIN     20      8   18062     354   \n",
      "82329  82330  0.000000   arp       -   INT      1      0      46       0   \n",
      "82330  82331  0.000000   arp       -   INT      1      0      46       0   \n",
      "82331  82332  0.000009   udp       -   INT      2      0     104       0   \n",
      "\n",
      "               rate  ...    ct_dst_sport_ltm  ct_dst_src_ltm  is_ftp_login  \\\n",
      "0      9.090909e+04  ...                   1               2             0   \n",
      "1      1.250000e+05  ...                   1               2             0   \n",
      "2      2.000000e+05  ...                   1               3             0   \n",
      "3      1.666667e+05  ...                   1               3             0   \n",
      "4      1.000000e+05  ...                   1               3             0   \n",
      "5      3.333333e+05  ...                   1               2             0   \n",
      "6      1.666667e+05  ...                   1               2             0   \n",
      "7      3.571429e+04  ...                   1               3             0   \n",
      "8      0.000000e+00  ...                   2               2             0   \n",
      "9      0.000000e+00  ...                   2               2             0   \n",
      "10     0.000000e+00  ...                   2               2             0   \n",
      "11     0.000000e+00  ...                   2               2             0   \n",
      "12     2.500000e+05  ...                   1               3             0   \n",
      "13     1.428571e+05  ...                   1               3             0   \n",
      "14     9.090909e+04  ...                   1               1             0   \n",
      "15     2.500000e+05  ...                   1               3             0   \n",
      "16     3.333333e+05  ...                   1               2             0   \n",
      "17     1.000000e+05  ...                   1               2             0   \n",
      "18     5.000000e+05  ...                   1               2             0   \n",
      "19     2.500000e+05  ...                   1               2             0   \n",
      "20     1.000000e+05  ...                   1               2             0   \n",
      "21     1.111111e+05  ...                   1               2             0   \n",
      "22     1.000000e+05  ...                   1               3             0   \n",
      "23     2.000000e+05  ...                   1               3             0   \n",
      "24     3.333333e+05  ...                   1               3             0   \n",
      "25     1.428571e+05  ...                   1               2             0   \n",
      "26     1.666667e+05  ...                   1               2             0   \n",
      "27     5.000000e+05  ...                   1               1             0   \n",
      "28     1.428571e+05  ...                   1               1             0   \n",
      "29     1.045904e+01  ...                   1               1             0   \n",
      "...             ...  ...                 ...             ...           ...   \n",
      "82302  3.334838e+01  ...                   1               2             0   \n",
      "82303  1.724118e+01  ...                   1               2             0   \n",
      "82304  9.623964e+00  ...                   1               1             0   \n",
      "82305  1.463300e+01  ...                   1               1             0   \n",
      "82306  3.009842e+01  ...                   1               1             0   \n",
      "82307  1.750003e+01  ...                   1               2             0   \n",
      "82308  3.210183e+01  ...                   1               2             0   \n",
      "82309  1.656347e+01  ...                   1               2             0   \n",
      "82310  1.247196e+01  ...                   1               2             0   \n",
      "82311  1.687786e+01  ...                   1               2             0   \n",
      "82312  1.448527e+01  ...                   1               1             0   \n",
      "82313  1.111111e+05  ...                   1               1             0   \n",
      "82314  2.860227e+01  ...                   1               1             0   \n",
      "82315  1.000000e+06  ...                   1               2             0   \n",
      "82316  1.000000e+06  ...                   1               2             0   \n",
      "82317  1.583884e+01  ...                   1               4             0   \n",
      "82318  1.111111e+05  ...                   1               2             0   \n",
      "82319  1.847486e+01  ...                   1               4             0   \n",
      "82320  1.000000e+05  ...                   1               2             0   \n",
      "82321  1.000000e+06  ...                   1               2             0   \n",
      "82322  2.500000e+05  ...                   1               1             0   \n",
      "82323  2.535119e+01  ...                   1               1             0   \n",
      "82324  1.666667e+05  ...                   1               2             0   \n",
      "82325  1.000000e+05  ...                   1               2             0   \n",
      "82326  1.111111e+05  ...                   1               1             0   \n",
      "82327  2.000000e+05  ...                   1               2             0   \n",
      "82328  2.441007e+01  ...                   1               1             0   \n",
      "82329  0.000000e+00  ...                   1               1             0   \n",
      "82330  0.000000e+00  ...                   1               1             0   \n",
      "82331  1.111111e+05  ...                   1               1             0   \n",
      "\n",
      "       ct_ftp_cmd  ct_flw_http_mthd  ct_src_ltm  ct_srv_dst  is_sm_ips_ports  \\\n",
      "0               0                 0           1           2                0   \n",
      "1               0                 0           1           2                0   \n",
      "2               0                 0           1           3                0   \n",
      "3               0                 0           2           3                0   \n",
      "4               0                 0           2           3                0   \n",
      "5               0                 0           2           2                0   \n",
      "6               0                 0           2           2                0   \n",
      "7               0                 0           1           3                0   \n",
      "8               0                 0           2           2                1   \n",
      "9               0                 0           2           2                1   \n",
      "10              0                 0           2           2                1   \n",
      "11              0                 0           2           2                1   \n",
      "12              0                 0           1           3                0   \n",
      "13              0                 0           1           3                0   \n",
      "14              0                 0           1           1                0   \n",
      "15              0                 0           2           3                0   \n",
      "16              0                 0           1           2                0   \n",
      "17              0                 0           1           2                0   \n",
      "18              0                 0           1           2                0   \n",
      "19              0                 0           2           2                0   \n",
      "20              0                 0           1           2                0   \n",
      "21              0                 0           1           2                0   \n",
      "22              0                 0           1           3                0   \n",
      "23              0                 0           2           3                0   \n",
      "24              0                 0           2           3                0   \n",
      "25              0                 0           2           2                0   \n",
      "26              0                 0           2           2                0   \n",
      "27              0                 0           2           1                0   \n",
      "28              0                 0           2           2                0   \n",
      "29              0                 0           1           1                0   \n",
      "...           ...               ...         ...         ...              ...   \n",
      "82302           0                 0           1           2                0   \n",
      "82303           0                 0           1           2                0   \n",
      "82304           0                 0           1           1                0   \n",
      "82305           0                 0           1           1                0   \n",
      "82306           0                 0           1           1                0   \n",
      "82307           0                 0           2           2                0   \n",
      "82308           0                 0           2           2                0   \n",
      "82309           0                 0           1           2                0   \n",
      "82310           0                 0           1           2                0   \n",
      "82311           0                 0           1           2                0   \n",
      "82312           0                 0           1           1                0   \n",
      "82313           0                 0           1           1                0   \n",
      "82314           0                 0           1           1                0   \n",
      "82315           0                 0           1           2                0   \n",
      "82316           0                 0           2           2                0   \n",
      "82317           0                 0           1           4                0   \n",
      "82318           0                 0           1           2                0   \n",
      "82319           0                 0           1           4                0   \n",
      "82320           0                 0           1           2                0   \n",
      "82321           0                 0           1           2                0   \n",
      "82322           0                 0           1           1                0   \n",
      "82323           0                 0           1           3                0   \n",
      "82324           0                 0           1           2                0   \n",
      "82325           0                 0           1           2                0   \n",
      "82326           0                 0           1           1                0   \n",
      "82327           0                 0           2           1                0   \n",
      "82328           0                 0           3           2                0   \n",
      "82329           0                 0           1           1                1   \n",
      "82330           0                 0           1           1                1   \n",
      "82331           0                 0           1           1                0   \n",
      "\n",
      "       attack_cat  label  \n",
      "0          Normal      0  \n",
      "1          Normal      0  \n",
      "2          Normal      0  \n",
      "3          Normal      0  \n",
      "4          Normal      0  \n",
      "5          Normal      0  \n",
      "6          Normal      0  \n",
      "7          Normal      0  \n",
      "8          Normal      0  \n",
      "9          Normal      0  \n",
      "10         Normal      0  \n",
      "11         Normal      0  \n",
      "12         Normal      0  \n",
      "13         Normal      0  \n",
      "14         Normal      0  \n",
      "15         Normal      0  \n",
      "16         Normal      0  \n",
      "17         Normal      0  \n",
      "18         Normal      0  \n",
      "19         Normal      0  \n",
      "20         Normal      0  \n",
      "21         Normal      0  \n",
      "22         Normal      0  \n",
      "23         Normal      0  \n",
      "24         Normal      0  \n",
      "25         Normal      0  \n",
      "26         Normal      0  \n",
      "27         Normal      0  \n",
      "28         Normal      0  \n",
      "29         Normal      0  \n",
      "...           ...    ...  \n",
      "82302      Normal      0  \n",
      "82303      Normal      0  \n",
      "82304      Normal      0  \n",
      "82305      Normal      0  \n",
      "82306      Normal      0  \n",
      "82307      Normal      0  \n",
      "82308      Normal      0  \n",
      "82309      Normal      0  \n",
      "82310      Normal      0  \n",
      "82311      Normal      0  \n",
      "82312      Normal      0  \n",
      "82313      Normal      0  \n",
      "82314      Normal      0  \n",
      "82315      Normal      0  \n",
      "82316      Normal      0  \n",
      "82317      Normal      0  \n",
      "82318      Normal      0  \n",
      "82319      Normal      0  \n",
      "82320      Normal      0  \n",
      "82321      Normal      0  \n",
      "82322      Normal      0  \n",
      "82323      Normal      0  \n",
      "82324      Normal      0  \n",
      "82325      Normal      0  \n",
      "82326      Normal      0  \n",
      "82327      Normal      0  \n",
      "82328      Normal      0  \n",
      "82329      Normal      0  \n",
      "82330      Normal      0  \n",
      "82331      Normal      0  \n",
      "\n",
      "[82332 rows x 45 columns]>\n"
     ]
    }
   ],
   "source": [
    "print (df.dtypes)\n",
    "print (df.info)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "normal packet percentage:  44.939999028324344\n",
      "attack packet percentage:  55.06000097167566\n"
     ]
    }
   ],
   "source": [
    "normalPacketPercent = float(len(df[df.label==0]))/len(df)*100.0\n",
    "attackPacketPercent = float(len(df[df.label==1]))/len(df)*100.0\n",
    "\n",
    "print ('normal packet percentage: ',  nonAttackCnt)\n",
    "print ('attack packet percentage: ',  attackCnt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [Root]",
   "language": "python",
   "name": "Python [Root]"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
